#!/usr/bin/env python
# -*- coding: utf-8 -*-

import click
import json
import io
import os
import sys

@click.group()
def main():
    pass



@click.command()
@click.option('--platform', '-p', default = 'all', type = click.Choice(['all', 'ios', 'win32', 'android']), help = u'Select the platform of app')
def cfg(platform):
    """
    todo:导出配置
    """
    #parse_config(platform)

@click.command()
def audio():
    """
    todo：导出音频
    """
    pass

@click.command()
def ui():
    """
    todo：导出UI
    """
    pass

@click.command()
@click.option('-i', '--input-path', required = False, help = u'input_path')
@click.option('-l', '--output-path', required = False, help = u'output_path')
def bt(**options):
    """
    导出行为树，用于逻辑编辑，引导/技能等
    """

    click.echo('Export behavior-tree about the unit.')
    click.echo('Start:')
    from clitool.core.task.behavior.ExportLuaTreeTask import ExportLuaTreeTask
    task = ExportLuaTreeTask(options)
    task.run()
    click.echo('Finish.')


@click.command()
@click.option('-n', '--name', required = False, help = u'project name')
@click.option('-p', '--platform', required = True, type = click.Choice(['wechatgame', 'android', 'ios', 'win32', 'huawei']), help = u'Build platform.')
def spine(**options):
    """
    spine合图程序，png合图，重写atlas文件，降低Drawcall
    """

    click.echo('split and pack texture')
    click.echo('Start:')
    from clitool.core.task.spine.ExportSpineTask import ExportSpineTask
    task = ExportSpineTask(options)
    task.run()
    click.echo('Finish.')
    pass

@click.command()
@click.option('-n', '--name', required = False, help = u'project name')
@click.option('-m', '--mode', default = 'debug', type = click.Choice(['debug', 'release']), help = u'Select publish mode.')
@click.option('-p', '--platform', required = True, type = click.Choice(['wechatgame', 'android', 'ios', 'win32', 'huawei']), help = u'Build platform.')
def publish(**options):
    """
        构建CocosCreator项目
    """
    from clitool.core.task.cocos.CocosBuildTask import CocosBuildTask
    task = CocosBuildTask(options)
    task.run()

    pass


main.add_command(bt)
main.add_command(cfg)
main.add_command(audio)
main.add_command(ui)
main.add_command(spine)
main.add_command(publish)


if __name__ == '__main__':
    main()